home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / setbit.asm < prev    next >
Assembly Source File  |  1985-06-03  |  1KB  |  54 lines

  1.     include c:sm8086.mac    ;
  2. longdata = 0            ;
  3. longprog = 0            ;
  4.     dseg            ;
  5. eighty    db    80        ; for multiply
  6. bits    db    80h        ; bit table
  7.     db    40h        ;
  8.     db    20h        ;
  9.     db    10h        ;
  10.     db    08h        ;
  11.     db    04h        ;
  12.     db    02h        ;
  13.     db    01h        ;
  14.         endds             ;
  15.     pseg            ;
  16.     public  setbit,grinit   ;
  17. setbit    proc    near
  18. x    equ    4
  19.     push    bp
  20.     mov    bp,sp
  21.     push    es
  22.     mov    ax,0b800h    ; color memory address
  23.     mov    es,ax        ; to extra seg register
  24.     mov    al,[bp+x+2]    ; row (y coordinate)
  25.     mov    dx,[bp+x]    ; col (x coordinate)
  26.     shr    al,1        ; carry bit means it's in high chunk
  27.     jc    odd        ; 
  28.     mov    di,0        ; in low chunk
  29.     jmp     comn        ;
  30. odd:    mov    di,2000h    ; in high chunk
  31. comn:    mul    eighty        ;            
  32.     add    di,ax        ; byte offset
  33.     mov    si,dx        ; column number
  34.     shr    dx,1        ; shift off bottom 3 bits
  35.     shr    dx,1        ;
  36.     shr     dx,1        ;
  37.     add    di,dx        ; final byte offset
  38.     and    si,7        ; SI has bit in byte
  39.     mov    ah,es:[di]    ; current byte contents
  40.     or    ah,[bits+si]    ; set desired bit
  41.     mov    es:[di],ah    ; store back
  42.     pop    es        ; restore old ES
  43.     pop    bp        ; and old BP
  44.     ret            ; return
  45. setbit    endp            ;
  46. grinit  proc near        ;
  47.     mov     ax,6        ; high res graphics
  48.     int    10h        ;
  49.     ret            ;
  50. grinit  endp            ;
  51.     endps            ;
  52.     end            ;
  53.     
  54.